<?php
  include("../Includes/FusionCharts_Gen.php");
  include("../Includes/DBConn.php");
?>
<HTML xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>UPLB DV</title>
		<script language="Javascript" src="../js/FusionCharts.js"></script>
		<link href="../css/960.css" rel="stylesheet" type="text/css" />
		<link href="../css/reset.css" rel="stylesheet" type="text/css" />
		<link href="../css/text.css" rel="stylesheet" type="text/css" />
		<link href="../css/style.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../js/search.js"></script>

		<script type="text/javascript" src="../js/jquery-1.3.1.min.js"></script>
		<script type="text/javascript" src="../js/slide.js"></script>
		<script type="text/javascript" src="../js/loadgallery.js"></script>
		<link href="../css/slideshow.css" rel="stylesheet" type="text/css" />
		

		<script type="text/javascript">
			/*
			function loadXMLDoc()
			{
			alert("value changed");
			}
			*/
		</script>
	</HEAD>

	<BODY>
	<CENTER>
			<?php
				$courseCode = $_POST['courseCode'];
				$startAY = $_POST['startAY'];
				$endAY = $_POST['endAY'];
				$graph = $_POST['graph'];
				$yAxis = $_POST['yAxis'];
				
				$FC = new FusionCharts($graph,"650","300");
				$FC->setSwfPath("../FusionCharts/");
				$strParam="caption=$courseCode;subcaption=$yAxis;xAxisName=Academic Year;yAxisName=Frequency; formatNumberScale=0;decimalPrecision=0";
				$FC->setChartParams($strParam);
				$link = connectToDB();
				$strQuery = "select "."$yAxis".", academicYear from course where courseCode='$courseCode' and academicYear>="."$startAY"." and academicYear<="."$endAY";
				
				if($courseCode!=""){
					$result = mysql_query($strQuery) or die(mysql_error());
				}
				
				if ($result) 
				{
					$FC->addDataFromDatabase($result, $yAxis, "academicYear");
				}

				mysql_close($link);
				$FC->renderChart();
			?>
	</CENTER>
	</BODY>
</HTML>